package good

import (
	"api/internal/respons"
	"api/internal/svc"
	"api/internal/types"
	"context"
	"homepage_srv/homepageclient"

	"github.com/zeromicro/go-zero/core/logx"
)

type GoodAlbumsLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewGoodAlbumsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GoodAlbumsLogic {
	return &GoodAlbumsLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

// 商品相册详情
func (l *GoodAlbumsLogic) GoodAlbums(req *types.GoodAlbumsRequest) (resp *types.Response, err error) {
	albums, err := l.svcCtx.HomepageGrpc.GoodAlbums(l.ctx, &homepageclient.GoodAlbumsRequest{
		GoodId: uint64(req.GoodId),
	})
	if err != nil {
		return respons.Error(400, "服务端错误", err.Error()), err
	}

	return respons.Success(albums), nil
}
